package app.beit.finportal.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import app.beit.finportal.bean.DocumentsBean;
import app.beit.finportal.dao.DocumentsDao;
import app.beit.finportal.entity.Documents;
import app.beit.finportal.service.convert.DocumentsConvert;

@Service
public class DocumentsService {

	@Autowired
	private DocumentsDao documentsDao;
	
	public List<DocumentsBean> getAllBackdoor() throws Exception{
		final List<Documents> entities = this.documentsDao.getAllBackdoor();
		if(entities != null && entities.size() > 0){
			return DocumentsConvert.entityToBean(entities);
		}
		return null;
	}
	
	public List<DocumentsBean> getAll() throws Exception{
		final List<Documents> entities = this.documentsDao.getAll();
		if(entities != null && entities.size() > 0){
			return DocumentsConvert.entityToBean(entities);
		}
		return null;
	}
	
	public List<DocumentsBean> getAllLastestDate() throws Exception{
		final List<Documents> entities = this.documentsDao.getAllLastedDate();
		if(entities != null && entities.size() > 0){
			return DocumentsConvert.entityToBean(entities);
		}
		return null;
	}
	
	public void add(final DocumentsBean bean) throws Exception{
		this.documentsDao.add(DocumentsConvert.beanToEntity(bean));
	}
	
	public void update(final DocumentsBean bean) throws Exception{
		this.documentsDao.update(DocumentsConvert.beanToEntity(bean));
	}
	
	public void delete(final DocumentsBean bean) throws Exception{
		this.documentsDao.delete(DocumentsConvert.beanToEntity(bean));
	}
	
}
